package com.sk.bilibili.utils;

import com.google.zxing.common.BitMatrix;
import lombok.SneakyThrows;
import org.springframework.stereotype.Component;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.util.Base64;

/**
 * @author 邵康
 * @date 2021/11/22 15:19
 */
public class Base64Utils {

    @SneakyThrows
    public static String encode(ByteArrayOutputStream os) {
        byte[] bytes = os.toByteArray();
        bytes=Base64.getEncoder().encode(bytes);
        os.close();
        return "data:image/png;base64," + new String(bytes);
    }

}
